//
//  ViewController.m
//  JW_BasePorject
//
//  Created by JW on 2018/4/4.
//  Copyright © 2018年 JW. All rights reserved.
//

#import "ViewController.h"
#import "JWBaseTableView.h"
//#import "SGHttpTool.h"
#import "JSHAREService.h"
#import "JShareTool.h"
#import "MBProgressHUD+JW.h"

#import "NSDictionary+YYAdd.h"
#import "ZYHttpTool.h"
#import "BTNetworking.h"
#import "AFNetworking.h"
#import "ZYNetworkTool.h"

#import "TestingPaperVC.h"
#import "NSObject+ZYImageSize.h"

@interface ViewController ()

@property(nonatomic,strong)JWBaseTableView *tableView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

//    [self testShare];
//    [self testTableView];
//    [self testHttpTool];
//    [self testBTNetworking];
    [self testAFN];
    [self doPaper];
    
//    [self loadImage];
    
}
- (void)loadImage{
    CGSize size = [self jw_getImageSizeWithURL:@"http://cn-qinqimaifang-uat.oss-cn-hangzhou.aliyuncs.com/img/specialist/upload/spcetiicwlz1v_54e2e00fa8a6faf66168571654dbfee2.jpg"];
    NSLog(@"%@",NSStringFromCGSize(size));
    NSLog(@"%@",[UIFont familyNames]);
    
}

- (void)testHttpTool{
    [ZYHttpTool requestWithType:ZYRequestMethodGET urlString:@"http://app.haopeixun.org/index.php?g=apps&m=paper&a=getType" params:@{} success:^(id response) {
        DLog(@"我的:%@",response);
    } fail:^(NSError *error) {
        NSLog(@"%@",error);

    }];
    
}

- (void)testBTNetworking{
    [BTNetworking requestWithType:BTGet urlString:@"http://app.haopeixun.org/index.php?g=apps&m=paper&a=getType" params:@{} success:^(id response, NSString *stringData) {
        NSLog(@"第一次输出:%@",[response jsonPrettyStringEncoded]);
        NSLog(@"❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️");

        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:response options:NSJSONWritingPrettyPrinted error:nil];
        NSString *resultStr =[[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
        NSLog(@"第二次输出:%@",resultStr);


    } fail:^(NSError *error) {
        NSLog(@"%@",error);

    }];
}

- (void)testAFN{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
    NSLog(@"%@",manager.responseSerializer);
    [manager GET:@"http://app.haopeixun.org/index.php?g=apps&m=paper&a=getType" parameters:@{} progress:nil success:^(NSURLSessionTask *task, id responseObject) {
        NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response;
        NSDictionary *allHeaders = response.allHeaderFields;
        
        NSLog(@"响应header:%@", allHeaders);
        NSLog(@"%@",responseObject);
    }failure:^(NSURLSessionTask *operation, NSError *error) {
        NSLog(@"%@",error);
    }];
    
}



- (void)testShare{
//    [MBProgressHUD showLoadingImageToView:self.view];

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(100, 100, 100, 100);
    btn.backgroundColor = [UIColor redColor];
    [btn addTarget:self action:@selector(toShare) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
}



- (void)toShare{
//    [JShareTool setupJShareConfig];
//    JSHAREMessage *message = [JSHAREMessage message];
//    message.mediaType = JSHARELink;
//    [JShareTool shareViewAddSuperview:self.view withMessage:message];
    
//    double x = arc4random() % 1000;
//    NSLog(@"%.f",x);
    [MBProgressHUD showActivityMessage:@"加载中"];
}


- (void)doPaper{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(100, 100, 100, 100);
    btn.backgroundColor = [UIColor redColor];
    [btn addTarget:self action:@selector(click_paper:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
}

- (void)click_paper:(UIButton *)sender{
    [self.navigationController pushViewController:[TestingPaperVC new] animated:YES];
    
}

- (void)testOnlyStr{
//    NSTimeInterval time = [[NSDate date] timeIntervalSince1970]*1000;//毫秒
//    double i=time;
//    //NSTimeInterval返回的是double类型
//    NSString * uniqueString = [NSString stringWithFormat:@"%.f",i];
//    NSLog(@"字符串:%@",uniqueString);

}

- (void)testTableView{
    self.tableView = [[JWBaseTableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64) style:UITableViewStylePlain];
    [self.tableView registerCellClass:@"UITableViewCell" cellIdentifier:@"UITableViewCellID" modelClass:@"BaseModel"];
    
    [self.tableView initRefreshView];
    
    
    [self.view addSubview:self.tableView];
    self.tableView.url = @"111";
    self.tableView.emptyTitle = @"暂无数据";
//    self.tableView.parameter = [[SGParameter alloc] init];
    
//    self.tableView.parameter.body.data  = @{};
    [self.tableView reloadNewData];
    
}



@end
